﻿using INTEX.DataBase;
using INTEX.DataBase.Tools;
using ReflectionStudio.Core;
using ReflectionStudio.Core.Events;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.IO;
using System.Linq;
using System.Windows;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    {
        public void YCAEKPAID(DataSet db)
        {
            int x = 4, y = 1;
            string VKPPOSTYP = "";
            DataTable dtOutput = new DataTable();
            try
            {
                /*<DataGrid.Columns>
                        <DataGridTextColumn Header="付款日期" Binding="{Binding EKVAENDDAT}" Width="Auto"/>
                        <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=供应商}}" Binding="{Binding SELLER}" Width="Auto"/>
                        <DataGridTextColumn Header="生产单" Binding="{Binding PRODAUF}" Width="Auto"/>
                        <DataGridTextColumn Header="加工厂" Binding="{Binding EXFTY}" Width="Auto"/>
                        <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=采购单}}" Binding="{Binding EKAUF}" Width="Auto"/>
                        <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=我司编号}}" Binding="{Binding MAT}" Width="Auto"/>
                        <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=款号}}" Binding="{Binding ABPART}" Width="Auto"/>
                        <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=布行编号}}" Binding="{Binding Path=EXART}" Width="Auto"/>
                        <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=色号}}" Binding="{Binding Path=EXCOLOR}" Width="Auto"/>
                        <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=色名}}" Binding="{Binding CDES}" Width="Auto"/>
                        <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=部位}}" Binding="{Binding MATTYP}" Width="Auto" />
                        <DataGridTextColumn Header="需求数m" Binding="{Binding ABARESMG}" Width="Auto" />
                        <DataGridTextColumn Header="需求数kg" Binding="{Binding ABARESKG}" Width="Auto" />
                        <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=实数}}" Binding="{Binding ACTUALQTY}" Width="Auto" />
                        <DataGridTextColumn Header="单价" Binding="{Binding EKPPR}" Width="Auto" />
                        <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=单位}}" Binding="{Binding PUM}" Width="Auto" />
                        <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=金额}}" Binding="{Binding EKPVALUE}" Width="Auto" />
                        <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=付款金额}}" Binding="{Binding PAID}" Width="Auto" />
                        <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=采购员}}" Binding="{Binding Path=EKVEMPF}" Width="Auto" />
                        <DataGridTextColumn Header="{Binding Source={Localization:Translate Word=财务人员}}" Binding="{Binding Path=EKVAENDBEN}" Width="Auto" />
                    </DataGrid.Columns>
                </DataGrid.Columns>*/
                #region======Title===========
                exAgent.SetCellValue(3, 1, "付款日期"); dtOutput.Columns.Add("EKVAENDDAT", typeof(System.Decimal));
                exAgent.SetCellValue(3, 2, "供应商"); dtOutput.Columns.Add("SELLER", typeof(System.String));
                exAgent.SetCellValue(3, 3, "生产单"); dtOutput.Columns.Add("PRODAUF", typeof(System.String));
                exAgent.SetCellValue(3, 4, "加工厂"); dtOutput.Columns.Add("EXFTY", typeof(System.String));
                exAgent.SetCellValue(3, 5, "采购单"); dtOutput.Columns.Add("EKAUF", typeof(System.String));
                exAgent.SetCellValue(3, 6, "我司编号"); dtOutput.Columns.Add("MAT", typeof(System.String));
                exAgent.SetCellValue(3, 7, "款号"); dtOutput.Columns.Add("ABPART", typeof(System.String));
                exAgent.SetCellValue(3, 8, "布行编号"); dtOutput.Columns.Add("EXART", typeof(System.String));
                exAgent.SetCellValue(3, 9, "色号"); dtOutput.Columns.Add("EXCOLOR", typeof(System.String));
                exAgent.SetCellValue(3, 10, "色名"); dtOutput.Columns.Add("CDES", typeof(System.String));
                exAgent.SetCellValue(3, 11, "部位"); dtOutput.Columns.Add("MATTYP", typeof(System.String));
                exAgent.SetCellValue(3, 12, "需求数"); dtOutput.Columns.Add("RQTY", typeof(System.Decimal));
                exAgent.SetCellValue(3, 13, "单位"); dtOutput.Columns.Add("WAUEBM", typeof(System.String));
                exAgent.SetCellValue(3, 14, "实数"); dtOutput.Columns.Add("ACTUALQTY", typeof(System.Decimal));
                exAgent.SetCellValue(3, 15, "单价"); dtOutput.Columns.Add("EKPPR", typeof(System.Decimal));
                exAgent.SetCellValue(3, 16, "单位"); dtOutput.Columns.Add("PUM", typeof(System.String));
                exAgent.SetCellValue(3, 17, "金额"); dtOutput.Columns.Add("EKPVALUE", typeof(System.Decimal));
                exAgent.SetCellValue(3, 18, "付款金额"); dtOutput.Columns.Add("PAID", typeof(System.Decimal));
                exAgent.SetCellValue(3, 19, "采购员"); dtOutput.Columns.Add("EKVEMPF", typeof(System.String));
                exAgent.SetCellValue(3, 20, "财务人员"); dtOutput.Columns.Add("EKVAENDBEN", typeof(System.String)); 
                #endregion
                exAgent.RenameSheet(date);
                #region======ConvertData===
                #endregion 
          
                    exAgent.RenameSheet(date); 
                   
                    #region====Excel==========
                    dtOutput.Merge(dsSource.Tables["EKVRECH"],false,MissingSchemaAction.Ignore);
                    exAgent.DataTableToExcel(dtOutput, x, 1);
                    int count = dtOutput.Rows.Count;
                    //MergeSame(x, count);
                    exAgent.SetCellValue(1, 1, 1);
                    exAgent.BatchConvert2Number(4,12, count + 3, 15);
                    exAgent.BatchConvert2Number(4, 17, count + 3, 18);
                    exAgent.SetCellValue(1, 1, " ");
                    #endregion
                
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            finally
            {
                EventDispatcher.Instance.RaiseStatus("完成", StatusEventType.StopProgress);
            }
        }

    }
}